@import '@devui/theme/styles-var/devui-var.scss';

.#{$devui-prefix}-input-number {
  position: relative;
  display: inline-block;
  width: 80px;

  &:hover {
    .#{$devui-prefix}-input-number__input-box:not(.disabled) {
      border: 1px solid $devui-form-control-line-hover;
      padding-right: 24px;
    }

    .#{$devui-prefix}-input-number__control-buttons:not(.disabled) {
      display: flex;
      border-color: $devui-form-control-line-hover;
    }
  }

  &:focus-within {
    .#{$devui-prefix}-input-number__input-box:not(.disabled) {
      border: 1px solid $devui-form-control-line-active;
      padding-right: 24px;
    }

    .#{$devui-prefix}-input-number__control-buttons:not(.disabled) {
      display: flex;
      border-color: $devui-form-control-line-active;
    }
  }

  .#{$devui-prefix}-input-number__input-box {
    box-sizing: border-box;
    width: 100%;
    height: 32px;
    line-height: $devui-line-height-base;
    padding: 4px 8px;
    display: block;
    font-size: $devui-font-size;
    outline: none;
    border-radius: $devui-border-radius;
    border: 1px solid $devui-form-control-line;
    cursor: text;
    -moz-appearance: textfield;
    transition: border-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;

    &:not(.disabled) {
      background-color: $devui-base-bg;
      border-color: $devui-line;
      color: $devui-text;
    }

    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
      -webkit-appearance: none;
    }
  }

  .#{$devui-prefix}-input-number__control-buttons {
    box-sizing: border-box;
    position: absolute;
    right: 0;
    width: 22px;
    height: 100%;
    line-height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid transparent;
    border-left-color: $devui-line;
    border-radius: 0 $devui-border-radius $devui-border-radius 0;

    &.disabled {
      border-left-color: $devui-disabled-line;
    }

    .control-button {
      user-select: none;
      box-sizing: border-box;
      height: 50%;
      line-height: 50%;
      border-width: 0 1px;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: $devui-base-bg;
      transition: transform $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;

      &.control-inc svg {
        position: relative;
        top: 2px;
        transform: rotate(180deg);
      }

      &.control-dec svg {
        position: relative;
        bottom: 2px;
      }

      svg path {
        fill: $devui-text-weak;
      }

      &:not(.disabled) {
        cursor: pointer;

        &:hover {
          & > svg path {
            fill: $devui-icon-fill-active-hover;
          }
        }
      }

      &.disabled {
        & > svg path {
          fill: $devui-disabled-text;
        }
      }
    }
  }

  .#{$devui-prefix}-input-number__input-wrap {
    height: 100%;
  }

  .disabled {
    cursor: not-allowed;
  }
}

.#{$devui-prefix}-input-number--lg {
  height: 40px;
  .#{$devui-prefix}-input-number__input-box {
    font-size: $devui-font-size-lg;
    height: 100%;
  }

  .#{$devui-prefix}-input-number__control-buttons .control-button .#{$devui-prefix}-input-number__icon-arrow {
    width: 20px;
    height: 20px;
  }
}

.#{$devui-prefix}-input-number--md {
  height: 32px;
  .#{$devui-prefix}-input-number__input-box {
    font-size: $devui-font-size;
    height: 100%;
  }

  .#{$devui-prefix}-input-number__control-buttons .control-button .#{$devui-prefix}-input-number__icon-arrow {
    width: 18px;
    height: 18px;
  }
}

.#{$devui-prefix}-input-number--sm {
  height: 24px;

  .#{$devui-prefix}-input-number__input-box {
    font-size: $devui-font-size-sm;
    height: 100%;
  }

  .#{$devui-prefix}-input-number__control-buttons .control-button .#{$devui-prefix}-input-number__icon-arrow {
    width: 16px;
    height: 16px;
  }
}
